package com.xyh.transaction.controller;

import com.xyh.transaction.entity.Message;
import com.xyh.transaction.response.ResponseResult;
import com.xyh.transaction.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "消息管理")
@RestController
@RequestMapping("message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @ApiOperation(value = "消息列表接口", notes = "返回当前用户所有消息")
    @GetMapping("list")
    public ResponseResult<List<Message>> getMessageList() {
        List<Message> messageList = messageService.getMessageList();
        return ResponseResult.success("查询成功！", messageList);
    }

    @ApiOperation(value = "更新消息", notes = "根据id更新消息")
    @PostMapping("update")
    public ResponseResult<Void> updateMessage(@RequestBody Message message) {
        messageService.updateMessage(message);
        return ResponseResult.success("操作成功！", null);
    }
}
